//
//  LabelButton.m
//  03-UIGestureRecognzier
//
//  Created by 曹曹 on 16/7/18.
//  Copyright © 2016年 曹曹. All rights reserved.
//

#import "LabelButton.h"

@interface LabelButton ()
@property (nonatomic, strong) UILabel *label;
@property (nonatomic, strong) UIColor *textColor;
@end

@implementation LabelButton
- (instancetype)initWithFrame:(CGRect)frame
                        title:(NSString *)title
              backgroundColor:(UIColor *)color
                    textColor:(UIColor *)textColor
                       target:(id)target
                       action:(SEL)action {
    self = [super initWithFrame:frame];
    if (self) {
        _textColor = textColor;
        self.label = [[UILabel alloc] initWithFrame:self.bounds];
        _label.text = title;
        _label.textColor = textColor;
        _label.textAlignment = NSTextAlignmentCenter;
        _label.backgroundColor = color;
        _label.userInteractionEnabled = YES;
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:target action:action];
        [_label addGestureRecognizer:tap];
        [self addSubview:_label];
    }
    return self;
}
@end
